<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>模糊背景</title>
    <style>
        main {
            width: 100vw;
            height: 100vh;
            background: url("./main.jpeg");
            background-size: cover;
            transition: .6s filter;
        }

        .de-emphasized {
            filter: blur(10px) contrast(0.8) brightness(0.8);
        }

        dialog::backdrop {
            background-color: rgba(0, 0, 0, 0.6);
        }
    </style>
</head>
<body>
<main onclick="showDialog()">
</main>
<dialog onclick="closeDialog()">
    O HAI， I am a dialog. Click on me to dismiss
</dialog>
<script>
    function showDialog() {
        const dialog = document.querySelector('dialog');
        const main = document.querySelector('main');
        main.classList.add('de-emphasized');
        dialog.showModal();
    }

    function closeDialog() {
        const dialog = document.querySelector('dialog');
        const main = document.querySelector('main');
        main.classList.remove('de-emphasized');
        dialog.close();
    }
</script>
</body>
</html>
